<template>
    <div class="show" v-bind:class="{ hideWidth : !isShow }">
        <div class="canvas-wrap">
            <div class="canvas-content">
                <div class="canvas-tool">
                    <div class="clear" v-on:click="clear">清除结果</div>
                    <div class="hide" v-on:click="isShow = !isShow">
                        <i v-if="isShow" class="fa fa-chevron-right" aria-hidden="true"></i>
                        <i v-else class="fa fa-chevron-left" aria-hidden="true"></i>
                    </div>
                    <div class="full" v-on:click="full"></div>
                </div>
                <div id="mycanvas"></div>
                <pre id="output"></pre>
            </div>
        </div>
    </div>
</template>

<script>
export default {
  name: 'PyShow',
  data () {
    return {
      isFull: false,
      isShow: true
    }
  },
  methods: {
    clear: function () {
      document.getElementById('mycanvas').innerHTML = ''
      document.getElementById('output').innerHTML = ''
    },
    full: function () {
      this.isFull = true
    }
  }
}
</script>

<style scoped>
    .show{
        display: inline-block;
        width: 400px;
        height: 100%;
        border-left: 1px solid lightgray;
        float: right;
    }
    .canvas-wrap{
        height: calc( 100% - 48px);
        margin-top: 48px;
    }
    .canvas-content{
        height: 100%;
        display: flex;
        display: -webkit-flex;
        flex-direction: column;
        -webkit-flex-direction: column;
        flex-wrap: nowrap;
    }
    .canvas-tool{
        height: 50px;
    }
    .clear{
        display: inline-block;
        width: 100px;
        height: 28px;
        border-radius: 20px;
        border: 1px solid lightgray;
        text-align: center;
        line-height: 28px;
        cursor: pointer;
        margin-left: 20px;
        vertical-align: top;
        margin-top: 10px;
        font-size: 14px;
        color: gray;
    }
    .clear:hover{
        border-color: dodgerblue;
        color: dodgerblue;
    }
    .hideWidth{
        width: 60px;
    }
    .hideWidth>.canvas-wrap>.canvas-content>.canvas-tool>.clear,
    .hideWidth>.canvas-wrap>.canvas-content>.canvas-tool>.full,
    .hideWidth>.canvas-wrap>.canvas-content>#mycanvas,
    .hideWidth>.canvas-wrap>.canvas-content>pre{
        display: none;
    }
    #output{
        background-color: #323B4A;
        margin: 0;
        color: white;
        padding: 10px 0 0 0;
        font-size: 15px;
        width: 100%;
        height: calc( 50% - 60px);
        /*height: 50%;*/
        border: 0;
        text-indent: 1em;
        z-index: 10;
    }
    #mycanvas{
        background-color: white;
        outline: none;
        float: right;
        height: 50%;
    }
    .hide{
        color: gray;
        float: right;
        margin-top: 11px;
        line-height: 28px;
        width: 40px;
        height: 28px;
        border-bottom-left-radius: 20px;
        border-top-left-radius: 20px;
        border: 1px solid lightgray;
        display: inline-block;
        text-align: center;
        cursor: pointer;
    }
    .hide:hover{
        border-color: dodgerblue;
        color: dodgerblue;
    }
    .full{
        float: right;
        margin-top: 11px;
        margin-right: 20px;
        width: 50px;
        height: 28px;
        border-radius: 20px;
        border: 1px solid lightgray;
        display: inline-block;
        text-align: center;
        cursor: pointer;
        background-image: url("../assets/full-screen.png");
        background-size: 20px;
        background-repeat: no-repeat;
        background-position: center;
    }
    .full:hover{
        border-color: dodgerblue;
        background-image: url("../assets/full-screen-hover.png");
    }

</style>
